package com.bdbit.ChargingStation.controller;

import com.bdbit.ChargingStation.services.MqttServerService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HealthController {

    private final MqttServerService mqttServerService;

    public HealthController(MqttServerService mqttServerService) {
        this.mqttServerService = mqttServerService;
    }

    @GetMapping("/mqtt-health")
    public String checkMqttHealth() {
        if (mqttServerService.isConnected()) {
            return "MQTT连接状态: 已连接";
        } else {
            return "MQTT连接状态: 已断开";
        }
    }
}